//
// Created by Dinger on 2021/10/2.
//

#ifndef FUNDAMENTALS_OF_COMPILING_SEMANTIC_FORM_H
#define FUNDAMENTALS_OF_COMPILING_SEMANTIC_FORM_H

#include"stdafx.h"

using namespace std;

class Item {
private:
    int _id;
    string _type;
    string _name;
    int _value;
    bool _isAssignment;
public:
    Item();

    Item(int id, string type, string name);

    int getID() {
        return _id;
    }

    string getType() {
        return _type;
    }

    string getName() {
        return _name;
    }

    int getValue() {
        return _value;
    }

    bool getIsAssignment() {
        return _isAssignment;
    }

    void setID(int id) {
        _id = id;
    }

    void setType(string type) {
        _type = type;
    }

    void setName(string name) {
        _name = name;
    }

    void setValue(int value) {
        _value = value;
    }

    void setIsAssignment(bool isAssignment) {
        _isAssignment = isAssignment;
    }

    void outputItem();
};

class ItemForm {
private:
    map<string, Item> _itemForm;
    int _size;
public:
    ItemForm();

    map<string, Item> getItemForm() {
        return _itemForm;
    }

    void insertItemForm(string type, string name);

    void changeItemValue(string name, int value);

    bool isItemDefine(string name);
};

class QuaternaryFormula {
private:
    string _firstFormula;
    string _secondFormula;
    string _thirdFormula;
    string _forthFormula;

    string _label;
    string _outputString;

    void makeOutputString();

public:
    QuaternaryFormula() {};

    QuaternaryFormula(string firstFormula, string secondFormula, string thirdFormula, string forthFormula);

    QuaternaryFormula(string number, string name);

    string getLabel() {
        return _label;
    }

    string getForthFormula() {
        return _forthFormula;
    }

    string getOutputString() {
        return _outputString;
    }

    void setLabel(string label) {
        _label = label;
        makeOutputString();
    }

    void setForthFormula(string forthFormula) {
        _forthFormula = forthFormula;
        makeOutputString();
    }
};

#endif //FUNDAMENTALS_OF_COMPILING_SEMANTIC_FORM_H
